from messAround.model.bilibili import BiliBiliRankModel, BiliBiliSearchModel
import messAround.util.help as util


# B站热门排行榜
class BiliBiliRankPipeline(object):

    @staticmethod
    def process_item(item, spider):
        return util.make_write_data({
            'title': item['title'],
            'info': item['info'],
            'channel': item['channel'],
            'cover': item['cover'],
            'dynamic': item['dynamic'],
            'video': item['video'],
            'video_id': item['video_id'],
            'video_duration': item['video_duration'],
            'play': item['play'],
            'danmaku': item['danmaku'],
            'share': item['share'],
            'like': item['like'],
            'reply': item['reply'],
            'coin': item['coin'],
            'author_id': item['author_id'],
            'author_avatar': item['author_avatar'],
            'author_name': item['author_name'],
            'create_time': item['create_time'],
        }, item, BiliBiliRankModel)


# B站热搜
class BiliBiliSearchPipeline(object):

    @staticmethod
    def process_item(item, spider):
        return util.make_write_data({
            'link': item["link"],
            'keyword': item["keyword"],
        }, item, BiliBiliSearchModel)
